package com.daxiasoftware.xxx.controller;

import java.util.Map;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.daxiasoftware.xxx.entity.User;
import com.daxiasoftware.xxx.service.ExampleService;
import com.daxiasoftware.xxx.service.UserService;

/**
 * 代码生成器，参考源码测试用例：
 * <p>
 * /mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/generator/MysqlGenerator.java
 */
@Controller
@RequestMapping("admin/user")
public class UserController extends BaseController {
	@Autowired
	private UserService userService;
	@Autowired
	private ExampleService exampleService;
	
	@RequestMapping("list")
	public String list(Map<String, Object> map, Page<User> page) throws Exception {
		Wrapper<User> wrapper = new EntityWrapper<User>();
		page = userService.selectPage(page, wrapper);
		map.put("page", page);
		map.put("list", page.getRecords());
		return "admin/user/user_list";
	}

	@RequestMapping("detail")
	public String detail(Long id, Map<String, Object> map) throws Exception {
		map.put("n", userService.selectById(id));
		return "admin/user/user_list";
	}

	@ResponseBody
	@RequestMapping("delete")
	public String delete(Long id) throws Exception {
		return userService.deleteById(id) + "";
	}
}
